package com.bugjpa.dao;

import com.bugjpa.domain.Bug;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author: mayuanbao
 * @date: 2019-01-13 21:51
 * @description:
 */
@Repository(value = "bugDao")
public interface BugDao extends JpaRepository<Bug, Long> {
    /**
     * 获取各级别bug数量
     * @author mayuanbao
     * @date 2019-05-31 15:28
     * @return java.util.List<java.lang.Object[]>
     */

    @Query(value = "select b.level, count(level) from Bug b group by b.level")
    List<Object []> findGroupByLevel();

    @Query("select new map(b.level as level, count(level) as count) from Bug b group by b.level")
    List<Map<String, String>> findGroupByLevels();
}
